package cn.com.flower.admin.content.dao.persist.repository.impl;

import cn.com.flower.admin.content.dao.persist.mapper.ArticleMapper;
import cn.com.flower.admin.content.dao.persist.repository.IArticleRepository;
import cn.com.flower.admin.content.pojo.entity.Article;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Slf4j
@Repository
public class ArticleRepositoryImpl implements IArticleRepository {

    @Autowired
    private ArticleMapper articleMapper;
    @Override
    public int insert(Article article) {
        log.debug("开始执行【插入文章】的数据访问，参数{}"+article);
     return articleMapper.insert(article);
    }

    @Override
    public int countByCategory(Long categoryId) {
        log.debug("开始执行【查询名称的类别的数量】的数据访问，参数:{}",categoryId);
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("categoryId",categoryId);
        return articleMapper.selectCount(wrapper);
    }
}
